package thread3;

import java.util.Scanner;

public class Test1 {
    public static volatile int isQuit = 0;
    private Object object = new Object();

    public static void main(String[] args) {
        Test1 test1 = new Test1();
        Thread t = new Thread(() -> {
            synchronized (test1.object) {
                while (isQuit == 0) {

                }
                System.out.println("t 线程结束！");
            }
        });
        t.start();

        synchronized (test1.object) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("输入一个整数：");
            isQuit = scanner.nextInt();
            System.out.println("main 线程结束！");
        }
    }
}
